<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<h1>Get</h1>
		<button onclick="getByGet('http://poetry.apiopen.top/getTime')">获取当前日期和时间</button>
		<button onclick="getByGet('http://poetry.apiopen.top/sentences')">随机一句名言</button>
		<button onclick="getByGet('http://poetry.apiopen.top/poetryFull?count=1&page=1')">获取诗词列表-包含作者信息</button>
		<button onclick="getByGet('http://poetry.apiopen.top/poetryAuthor?count=2&page=1&name=李白')">获取诗词作者列表</button>
		<button onclick="getByGet('http://poetry.apiopen.top/poetry?count=2&page=1')">获取诗词列表</button>
		<h1>Post</h1>
		<button onclick="getByPost('https://api.apiopen.top/getWangYiNews','1','1','1')">获取网易新闻</button>
		<button onclick="getByPost('https://api.apiopen.top/getImages','1','1','1')">美图推荐</button>
		<button onclick="getByPost('https://api.apiopen.top/likePoetry','李白','1','2')">模糊搜索古诗词-李白</button>
		<button onclick="getByPost('https://api.apiopen.top/searchPoetry','古风二首 二','1','2')">获取-古风二首 二</button>
		<button onclick="getByPost('https://api.apiopen.top/searchAuthors','李白','1','2')">搜索古诗词作者-李白</button>
	</body>

	<script>
		function getByGet(url) {
			var req = new XMLHttpRequest();
			req.open("get", url);
			req.send();
			req.onreadystatechange = function() {
				if (req.readyState == 4 && req.status == 200) {
					console.log(req.responseText);
				}
			}
		}

		function getByPost(url, par1, par2, choose) {
			var req = new XMLHttpRequest();
			req.open("post", url);
			if (choose == "1") {
				req.send("page=" + par1 + "&count=" + par2);
			} else if (choose == "2") {
				req.send("name=" + par1);
			}
			req.onreadystatechange = function() {
				if (req.readyState == 4 && req.status == 200) {
					console.log(req.responseText);
				}
			}
		}
	</script>
</html>